package com.caimiao.miao.http.retorfit;

import com.caimiao.miao.library.utils.QrBmpUtil;
import com.caimiao.miao.library.utils.storage.PrefUtil;

public class HttpConfig {
    public static final long HTTP_CONNECT_TIMEOUT = 30 * 1000;
    public static final String BASE_URL = "http://miaoapp.fangwei114.cn/";
    public static final int STATE_SUCCESS = 1;

    private static String mBaseUrl;

    public static String getBaseUrl() {
        if (mBaseUrl == null) {
            mBaseUrl = PrefUtil.getBaseUrl();
            if (mBaseUrl == null) mBaseUrl = BASE_URL;
        }
        return mBaseUrl;
    }

    public static void setBaseUrl(String baseUrl) {
        //更新当前baseUrl
        mBaseUrl = baseUrl;
        //必须清除二维码缓存的bitmap
        QrBmpUtil.clear();
        //必须清除Retrofit的BaseUrl
        RetrofitFactory.clear();
        //缓存baseUrl
        PrefUtil.saveBaseUrl(baseUrl);
    }
}
